<?php
include '../lib/Useradmin.php';
$userOb = new Useradmin();
$idUsers = '';
if (isset($_GET['idUsers'])) {
    $idUsers = $_GET['idUsers'];
}
$tv = $userOb->layThanhVien($idUsers);
if (empty($tv)) {
    header("Location: /admin/index.php");
}

$message = array();
if (isset($_POST['capnhat'])) {
    if ($userOb->capnhapThanhVien($idUsers,$_POST)) {
        $message[] = "Cập nhật thành công";
    } else {
        $message[] = "Cập nhật thất bại";
    }
}
?>
<form method="post" action="">
    <table style="margin: 10px auto" width="500px" border="1" align="center" cellspacing="1">
        <tr>
            <td bgcolor="#00CCFF" colspan="2"><p align="center"><b>Thông tin tài khoản</b></p></td>         
        </tr>
        <?php if (count($message) > 0): ?>
            <tr>
                <td colspan="2">
                    <?php foreach ($message as $mes): ?>
                        <p><?php echo $mes ?></p>
                    <?php endforeach; ?>
                </td>         
            </tr>
        <?php endif; ?>
        <tr>
            <td width="150px" align="right">Tên tài khoản:</td>
            <td><strong><?php echo $tv['UserName'] ?></strong></td>
        </tr>
        <tr>
            <td width="150px" align="right">Họ:</td>
            <td><input type="text" value="<?php echo $tv['FirstName'] ?>"  name="FirstName" id="FirstName" size="40px" /></td>
        </tr>
        <tr>
            <td width="150px" align="right">Tên:</td>
            <td><input type="text" value="<?php echo $tv['LastName'] ?>"  name="LastName" id="LastName" size="40px" /></td>
        </tr>
        <tr>
            <td width="150px" align="right">Email:</td>
            <td><input type="text" value="<?php echo $tv['Email'] ?>"  name="Email" id="Email" size="40px" /></td>
        </tr>
        <tr>
            <td width="150px" align="right">Ngày sinh:</td>
            <td><input type="text" value="<?php echo $tv['Birthday'] ?>" name="Birthday" id="Birthday" size="40px" /></td>
        </tr>
        <tr>
            <td width="150px" align="right">Nơi ở:</td>
            <td><input type="text" value="<?php echo $tv['Location'] ?>" name="Location" id="Location" size="40px" /></td>
        </tr>
        <tr>
            <td width="150px" align="right">Điện thoại:</td>
            <td><input type="text" value="<?php echo $tv['PhoneNum'] ?>" name="PhoneNum" id="PhoneNum" size="40px" /></td>
        </tr>
        <tr>
            <td align="right"><input type="submit" name="capnhat" id="capnhat" value="Cập nhật"</td>
        </tr>
    </table>
</form>
